package QuestionDaily;

import leetcode_101_120.levelOrderBottom_107;
import org.junit.Test;
import utils.TreeNode;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class TestDaily {

    @Test
    //765.相同的树
    public void test_11_11(){
        int []a={0,2,1,3};
        System.out.println(new minSwapsCouples_765().minSwapsCouples(a));
    }

    @Test
    //715. Range 模块
    public void test_11_12(){
        RangeModule rangeModule = new RangeModule();

        rangeModule.addRange(6, 8);


        rangeModule.removeRange(7, 8);


        rangeModule.removeRange(8, 9);


        rangeModule.addRange(8, 9);


        rangeModule.removeRange(1, 3);

        rangeModule.addRange(1, 8);


        System.out.println(rangeModule.queryRange(2, 4));
        System.out.println(rangeModule.queryRange(2, 9));
        System.out.println(rangeModule.queryRange(4, 6));
    }

    @Test
    //2656.相同的树
    public void test_11_15(){
        int []a={1,2,3,4,5};
        System.out.println(new maximizeSum_2656().maximizeSum(a,3));
    }

    @Test
    //2760. 最长奇偶子数组
    public void test_11_16(){
        int []a={8,10,7,8,3};
        System.out.println(new longestAlternatingSubarray_2760().longestAlternatingSubarray(a,9));
    }

    @Test
    //2736. 最大和查询
    public void test_11_17(){
        int []a={4,3,1,2};
        int []b={2,4,9,5};
        int [][]q={{4,1},{1,3},{2,5}};
        System.out.println(Arrays.toString(new maximumSumQueries_2736().maximumSumQueries2(a, b, q)));
    }

    @Test
    //2342. 数位和相等数对的最大和
    public void test_11_18(){
        int []a={18,43,36,13,7};
        System.out.println(new maximumSum_2342().maximumSum2(a));
    }

    @Test
    //689. 三个无重叠子数组的最大和
    public void test_11_19(){
        int []a={1,2,1,2,6,7,5,1};
        System.out.println(Arrays.toString(new maxSumOfThreeSubarrays_689().maxSumOfThreeSubarrays(a, 2)));
    }

    @Test
    //2216. 美化数组的最少删除数
    public void test_11_21(){
        int []a={1,6,9,9};
        System.out.println(new minDeletion_2216().minDeletion(a));
    }

    @Test
    //2304. 网格中的最小路径代价
    public void test_11_22(){
        int [][]grid={{5,3},{4,0},{2,1}};
        int [][]moveCost={{9,8},{1,5},{10,12},{18,6},{2,4},{14,3}};
        System.out.println(new minPathCost_2304().minPathCost(grid,moveCost));
    }

    @Test
    //1410. HTML 实体解析器
    public void test_11_23(){
        String text = "&lt";
        System.out.println(new entityParser_1410().entityParser(text));
    }

    @Test
    //2824. 统计和小于目标的下标对数目
    public void test_11_24(){
        List<Integer>a=new ArrayList<>();
        a.add(-1);
        a.add(1);
        a.add(2);
        a.add(3);
        a.add(1);
        System.out.println(new countPairs_2824().countPairs(a,2));
    }

    @Test
    //1457. 二叉树中的伪回文路径
    public void test_11_25(){
        TreeNode treeNode1=new TreeNode(2);
        TreeNode treeNode2=new TreeNode(3);
        TreeNode treeNode3=new TreeNode(1);

        TreeNode treeNode4=new TreeNode(3);
        TreeNode treeNode5=new TreeNode(1);

        TreeNode treeNode6=new TreeNode(5);
        TreeNode treeNode7=new TreeNode(1);

        treeNode1.left=treeNode2;
        treeNode1.right=treeNode3;

        treeNode2.left=treeNode4;
        treeNode2.right=treeNode5;

       // treeNode3.left=treeNode6;
        treeNode3.right=treeNode7;

        System.out.println(new pseudoPalindromicPaths_1457().pseudoPalindromicPaths(treeNode1));
    }

    @Test
    //828. 统计子串中的唯一字符
    public void test_11_26(){
        String text = "ABC";
        System.out.println(new uniqueLetterString_828().uniqueLetterString(text));
    }

    @Test
    //907. 子数组的最小值之和
    public void test_11_27(){
        int []a={11,81,94,43,3};
        System.out.println(new sumSubarrayMins_907().sumSubarrayMins2(a));
    }

    @Test
    //1670. 设计前中后队列
    public void test_11_28(){
        FrontMiddleBackQueue q = new FrontMiddleBackQueue();
        q.pushFront(1);   // [1]
        q.pushBack(2);    // [1, 2]
        q.pushMiddle(3);  // [1, 3, 2]
        q.pushMiddle(4);  // [1, 4, 3, 2]
        q.popFront();     // 返回 1 -> [4, 3, 2]
        q.popMiddle();    // 返回 3 -> [4, 2]
        q.popMiddle();    // 返回 4 -> [2]
        q.popBack();      // 返回 2 -> []
        q.popFront();     // 返回 -1 -> [] （队列为空）
    }

    @Test
    //2336. 无限集中的最小数字
    public void test_11_29(){
        SmallestInfiniteSet smallestInfiniteSet = new SmallestInfiniteSet();
        smallestInfiniteSet.popSmallest();
        smallestInfiniteSet.addBack(1);
        smallestInfiniteSet.popSmallest();
        smallestInfiniteSet.popSmallest();
        smallestInfiniteSet.popSmallest();
        smallestInfiniteSet.addBack(2);
        smallestInfiniteSet.addBack(3);
        smallestInfiniteSet.popSmallest();
        smallestInfiniteSet.popSmallest();
    }

    @Test
    //1657. 确定两个字符串是否接近
    public void test_11_30(){
        String text1 = "abbzzca";
        String text2 = "babzzcz";
        System.out.println(new closeStrings_1657().closeStrings(text1,text2));
    }

    @Test
    //2661. 找出叠涂元素
    public void test_12_1(){
        int []a={1,4,5,2,6,3};
        int[][] b={{4,3,5},{1,2,6}};
        System.out.println(new firstCompleteIndex_2661().firstCompleteIndex(a,b));
    }

    @Test
    //1094. 拼车
    public void test_12_2(){
        int[][] b={{2,1,5},{3,3,7}};
        System.out.println(new carPooling_1094().carPooling(b,4));
    }

    @Test
    //1423. 可获得的最大点数
    public void test_12_3(){
        int []a={9,7,7,9,7,7,9};
        System.out.println(new maxScore_1423().maxScore(a,7));
    }

    @Test
    //1038. 从二叉搜索树到更大和树
    public void test_12_4(){
        TreeNode treeNode1=new TreeNode(4);
        TreeNode treeNode2=new TreeNode(1);
        TreeNode treeNode3=new TreeNode(6);

        TreeNode treeNode4=new TreeNode(0);
        TreeNode treeNode5=new TreeNode(2);
        TreeNode treeNode8=new TreeNode(3);

        TreeNode treeNode6=new TreeNode(5);
        TreeNode treeNode7=new TreeNode(7);
        TreeNode treeNode9=new TreeNode(8);

        treeNode1.left=treeNode2;
        treeNode1.right=treeNode3;

        treeNode2.left=treeNode4;
        treeNode2.right=treeNode5;
        treeNode5.right=treeNode8;

        treeNode3.left=treeNode6;
        treeNode3.right=treeNode7;
        treeNode7.right=treeNode9;
        System.out.println(new bstToGst_1038().bstToGst(treeNode1));
    }

    @Test
    //12477. 到达首都的最少油耗
    public void test_12_5(){
        int[][] b={{3,1},{3,2},{1,0},{0,4},{0,5},{4,6}};

    }

    @Test
    //2646. 最小化旅行的价格总和
    public void test_12_6(){
        int[][] edges={{0,1},{1,2},{1,3}};
        int [] price={2,2,10,6};
        int[][] trips={{0,3},{2,1},{2,3}};
        System.out.println(new minimumTotalPrice_2646().minimumTotalPrice(4,edges,price,trips));
    }

    @Test
    //2646. 最小化旅行的价格总和
    public void test_12_7(){
        int[][] connections={{0,1},{1,3},{2,3}};
        System.out.println(new minReorder_1466().minReorder(6,connections));
    }
}
